<?php
define('INTERNAL_FLAG', true);

include($_SERVER["DOCUMENT_ROOT"]."/_symp/connect_db.php");
include($_SERVER["DOCUMENT_ROOT"]."/_symp/_function/all_function.php");
include($_SERVER["DOCUMENT_ROOT"]."/session.php");
include($_SERVER["DOCUMENT_ROOT"]."/lang.php");

if (isset($_REQUEST["lang"]) && in_array($_REQUEST["lang"], $array_lang)) {
	define("SEL_LANG", strtolower($_REQUEST["lang"]));
} else {
	define("SEL_LANG", "ru");
}
include($_SERVER["DOCUMENT_ROOT"]."/_symp/parameters.php");

if (isset($_REQUEST["name"])) {
	$name = trim($_REQUEST["name"]);
} else {
	$name = "";
}
if (isset($_REQUEST["city"])) {
	$city = trim($_REQUEST["city"]);
} else {
	$city = "";
}
if (isset($_REQUEST["msg"])) {
	$msg = $_REQUEST["msg"];
} else {
	$msg = "";
}

$obliged_mas["name"] = true;
$obliged_mas["city"] = false;
$obliged_mas["msg"] = true;

$data_mas["name"] = $name;
$data_mas["city"] = $city;
$data_mas["msg"] = $msg;

foreach($data_mas as $field_name => $value) {
	if (empty($value) && $obliged_mas[$field_name]) {
		$arr_error_fields[$field_name] = $arr_error_fields[$field_name];
	}
}

if (empty($arr_error_fields)) {
	$subject = "Письмо с сайта Альянс Банка - Борьба с коррупцией";
	$message = '
	<html>
	<head>
	</head>
	<body>
	<br>
	'."Имя: ".$data_mas["name"].'<br>
	'."Город: ".$data_mas["city"].'<br>
	'."Cообщение: ".$data_mas["msg"].'<br>
	</body>
	</html>';
	$headers  = "MIME-Version: 1.0\r\n";
	$headers .= "Content-type: text/html; charset=utf-8\r\n";
	$headers .= "From: info@alb.kz\r\n";
	$mail = explode("\r\n", P_HEAD_MAIL_CORUP);
	for ($i=0;$i<sizeof($mail);$i++) {
		if ($mail[$i]!='') {
			@mail($mail[$i], $subject,  wordwrap($message, 76, "\r\n", 0), $headers);
		}
	}
}


if (empty($arr_error_fields)) {
	$xml_exp .= '<glob_message>'.M2.'</glob_message>';
	$xml_exp .= '<accept>1</accept>';
} else { //Вывод ошибки при сохранении
	$xml_exp .= '<glob_message>'.M3.'</glob_message>';
	$xml_exp .= '<accept>0</accept>';
 	if (sizeof($arr_error_fields)) {
		foreach($arr_error_fields as $field => $message) {
			$xml_exp .= '<filed name="'.$field.'">'.$message.'</filed>';
		}
	}

}

header('Content-Type: text/xml');
$xml_export  = '<?xml version="1.0" encoding="UTF-8"  standalone="yes"?>';
$xml_export .= '<xml>';
$xml_export .= $xml_exp;
$xml_export .= '</xml>';
print $xml_export;
?>